<?php
/**
 * Created by PhpStorm.
 * User: soulmates
 * Date: 2017/8/15
 * Time: 上午8:13
 */
namespace app\restaurantadmin\model;
use think\Model;
use Captcha;

class Login extends Model
{
    public function login($adminname,$adminpass){
        $admin= \think\Db::name('shopadmins')->where('adminname',$adminname)->find();//查找数据(注意：查询出的密码是经过MD5加密的)
       
        if($admin){
            if($admin['adminpass']==think_weiphp_md5($adminpass)){
                \think\Session::set('id',$admin['id']);//id是查询到的管理员的id，写入session
                \think\Session::set('radminname',$admin['adminname']);//将adminname写入session
                \think\Session::set('sta',$admin['sta']);
                return 1;//登录成功
            }else{
                return 2;//用户名密码不匹配，登录失败
            }
        }else{
            return 3;//用户不存在，登录失败
        }

    }

}
